/*
 * AntGeneratorGUIView.java
 */

package antgeneratorgui;

import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.text.DefaultCaret;
import naming.PathContainer;
import naming.PathNames;
import processes.InitProperties;
import processes.StreamGobbler;

/**
 * The application's main frame.
 */


public class AntGeneratorGUIView extends FrameView {

    File currDirFile;
    Properties generalProper = new Properties();
    Boolean flagKeyPress = false;

    public AntGeneratorGUIView(SingleFrameApplication app) throws IOException {
        super(app);
        generalProper = InitProperties.initGeneralProper();
        initComponents();
    }
    
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = AntGeneratorGUIApp.getApplication().getMainFrame();
            aboutBox = new AntGeneratorGUIAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        AntGeneratorGUIApp.getApplication().show(aboutBox);
    }

    @Action
    public void showOpciones() {
        if (dialogOpciones == null) {
            JFrame mainFrame = AntGeneratorGUIApp.getApplication().getMainFrame();
            //dialogOpciones = new optionDialog(mainFrame,generalProper,eclipseProper,puttyProper,areaCon);
            dialogOpciones = new optionDialog(mainFrame,generalProper,areaCon);
            dialogOpciones.setLocationRelativeTo(mainFrame);
        }
        AntGeneratorGUIApp.getApplication().show(dialogOpciones);

        dialogOpciones.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e){
                dialogOpciones = null;
            }
        });
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        scrollCon = new javax.swing.JScrollPane();
        areaCon = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        btn_antgeneratewp = new javax.swing.JButton();
        btn_ant = new javax.swing.JButton();
        btn_antdeploy = new javax.swing.JButton();
        btn_antupdate = new javax.swing.JButton();
        btn_dependencies_flex = new javax.swing.JButton();
        btn_dependencies_web = new javax.swing.JButton();
        btn_dependencies_java = new javax.swing.JButton();
        btn_generate_tar = new javax.swing.JButton();
        panel_apps = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        btn_wiki = new javax.swing.JButton();
        btn_ambientes = new javax.swing.JButton();
        btn_artifactory = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        btn_clear = new javax.swing.JButton();
        btn_selproy = new javax.swing.JButton();
        txt_diractual = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        btn_custom_comm = new javax.swing.JButton();
        txt_custom_command = new javax.swing.JTextField();
        btn_execute = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(750, 639));

        scrollCon.setAutoscrolls(true);
        scrollCon.setName("scrollCon"); // NOI18N

        DefaultCaret caret = (DefaultCaret)areaCon.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        areaCon.setBackground(Color.decode(generalProper.getProperty("bgColor")));
        areaCon.setColumns(20);
        areaCon.setFont(new java.awt.Font("Lucida Console", 0, 13));
        areaCon.setForeground(Color.decode(generalProper.getProperty("fontColor")));
        areaCon.setRows(5);
        areaCon.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        areaCon.setName("areaCon"); // NOI18N
        scrollCon.setViewportView(areaCon);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Acciones Principales", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jPanel2.setName("jPanel2"); // NOI18N

        btn_antgeneratewp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_antgeneratewp.setText("Generate Workspace");
        btn_antgeneratewp.setEnabled(false);
        btn_antgeneratewp.setName("btn_antgeneratewp"); // NOI18N
        btn_antgeneratewp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_antgeneratewpActionPerformed(evt);
            }
        });

        btn_ant.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_ant.setText("ANT");
        btn_ant.setEnabled(false);
        btn_ant.setName("btn_ant"); // NOI18N
        btn_ant.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_antActionPerformed(evt);
            }
        });

        btn_antdeploy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_antdeploy.setText("Deploy");
        btn_antdeploy.setEnabled(false);
        btn_antdeploy.setName("btn_antdeploy"); // NOI18N
        btn_antdeploy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_antdeployActionPerformed(evt);
            }
        });

        btn_antupdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_antupdate.setText("Update");
        btn_antupdate.setEnabled(false);
        btn_antupdate.setName("btn_antupdate"); // NOI18N
        btn_antupdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_antupdateActionPerformed(evt);
            }
        });

        btn_dependencies_flex.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_dependencies_flex.setText("Dependencies Flex");
        btn_dependencies_flex.setEnabled(false);
        btn_dependencies_flex.setName("btn_dependencies_flex"); // NOI18N
        btn_dependencies_flex.setPreferredSize(new java.awt.Dimension(183, 37));
        btn_dependencies_flex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_dependencies_flexActionPerformed(evt);
            }
        });

        btn_dependencies_web.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_dependencies_web.setText("Dependencies Web");
        btn_dependencies_web.setEnabled(false);
        btn_dependencies_web.setName("btn_dependencies_web"); // NOI18N
        btn_dependencies_web.setPreferredSize(new java.awt.Dimension(183, 37));
        btn_dependencies_web.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_dependencies_webActionPerformed(evt);
            }
        });

        btn_dependencies_java.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_dependencies_java.setText("Dependencies Java");
        btn_dependencies_java.setEnabled(false);
        btn_dependencies_java.setName("btn_dependencies_java"); // NOI18N
        btn_dependencies_java.setPreferredSize(new java.awt.Dimension(183, 37));
        btn_dependencies_java.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_dependencies_javaActionPerformed(evt);
            }
        });

        btn_generate_tar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ant2.png"))); // NOI18N
        btn_generate_tar.setText("Generate TAR");
        btn_generate_tar.setEnabled(false);
        btn_generate_tar.setName("btn_generate_tar"); // NOI18N
        btn_generate_tar.setPreferredSize(new java.awt.Dimension(183, 37));
        btn_generate_tar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_generate_tarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btn_ant, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_antdeploy, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                    .addComponent(btn_antupdate, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                    .addComponent(btn_antgeneratewp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(41, 41, 41)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btn_dependencies_web, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE)
                    .addComponent(btn_dependencies_flex, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_dependencies_java, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_generate_tar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_ant)
                    .addComponent(btn_dependencies_flex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_antdeploy, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_dependencies_java, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_antupdate)
                    .addComponent(btn_dependencies_web, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btn_generate_tar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_antgeneratewp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        panel_apps.setBorder(javax.swing.BorderFactory.createTitledBorder("Aplicaciones"));
        panel_apps.setName("panel_apps"); // NOI18N

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Eclipse_icon.png"))); // NOI18N
        jButton2.setToolTipText("Ejecutar Eclipse");
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/putty_icon.png"))); // NOI18N
        jButton4.setToolTipText("Ejecutar PuTTY");
        jButton4.setName("jButton4"); // NOI18N
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/sqldev.png"))); // NOI18N
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/winscp-icon.png"))); // NOI18N
        jButton6.setToolTipText("Ejecutar PuTTY");
        jButton6.setName("jButton6"); // NOI18N
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        btn_wiki.setText("Wiki");
        btn_wiki.setName("btn_wiki"); // NOI18N
        btn_wiki.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_wikiActionPerformed(evt);
            }
        });

        btn_ambientes.setText("Ambientes");
        btn_ambientes.setName("btn_ambientes"); // NOI18N
        btn_ambientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_ambientesActionPerformed(evt);
            }
        });

        btn_artifactory.setText("Artifactory");
        btn_artifactory.setName("btn_artifactory"); // NOI18N
        btn_artifactory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_artifactoryActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panel_appsLayout = new javax.swing.GroupLayout(panel_apps);
        panel_apps.setLayout(panel_appsLayout);
        panel_appsLayout.setHorizontalGroup(
            panel_appsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_appsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_appsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_appsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(btn_artifactory, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panel_appsLayout.createSequentialGroup()
                            .addComponent(btn_wiki)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btn_ambientes)))
                    .addGroup(panel_appsLayout.createSequentialGroup()
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        panel_appsLayout.setVerticalGroup(
            panel_appsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_appsLayout.createSequentialGroup()
                .addGroup(panel_appsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(79, 79, 79)
                .addGroup(panel_appsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_wiki)
                    .addComponent(btn_ambientes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_artifactory)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Proyecto"));
        jPanel3.setName("jPanel3"); // NOI18N

        btn_clear.setText("Clear Console");
        btn_clear.setName("btn_clear"); // NOI18N
        btn_clear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_clearActionPerformed(evt);
            }
        });

        btn_selproy.setText("Seleccionar Proyecto");
        btn_selproy.setName("btn_selproy"); // NOI18N
        btn_selproy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_selproyActionPerformed(evt);
            }
        });

        txt_diractual.setEditable(false);
        txt_diractual.setName("txt_diractual"); // NOI18N
        //txt_diractual.setText(currDirFile.toString());

        jLabel1.setText("Carpeta Actual:");
        jLabel1.setName("jLabel1"); // NOI18N

        jButton3.setText("Abrir");
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        btn_custom_comm.setText("Comando Personalizado");
        btn_custom_comm.setEnabled(false);
        btn_custom_comm.setName("btn_custom_comm"); // NOI18N
        btn_custom_comm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_custom_commActionPerformed(evt);
            }
        });

        txt_custom_command.setEnabled(false);
        txt_custom_command.setName("txt_custom_command"); // NOI18N
        txt_custom_command.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_custom_commandActionPerformed(evt);
            }
        });
        txt_custom_command.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_custom_commandKeyTyped(evt);
            }
        });

        btn_execute.setText("Run");
        btn_execute.setEnabled(false);
        btn_execute.setName("btn_execute"); // NOI18N
        btn_execute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_executeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addComponent(btn_clear)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_custom_comm)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_custom_command, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(btn_selproy, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_diractual, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btn_execute, 0, 0, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_selproy)
                    .addComponent(jLabel1)
                    .addComponent(txt_diractual, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_clear)
                    .addComponent(btn_custom_comm)
                    .addComponent(txt_custom_command, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_execute)))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panel_apps, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
            .addComponent(scrollCon, javax.swing.GroupLayout.DEFAULT_SIZE, 698, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_apps, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollCon, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE)
                .addGap(1, 1, 1))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText("Archivo");
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(antgeneratorgui.AntGeneratorGUIApp.class).getContext().getActionMap(AntGeneratorGUIView.class, this);
        jMenuItem1.setAction(actionMap.get("showOpciones")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        fileMenu.add(jMenuItem1);

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText("Help");
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setComponent(mainPanel);
        setMenuBar(menuBar);
    }// </editor-fold>//GEN-END:initComponents

    private void btn_selproyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_selproyActionPerformed
        boolean isValid = false;
        JFileChooser chooser = new JFileChooser(generalProper.getProperty("defaultDir"));
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        int returnVal = chooser.showOpenDialog(null);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            if(chooser.getSelectedFile().isFile())
            {
                JOptionPane.showMessageDialog(null, "Debe Seleccionar una Carpeta","ERROR", JOptionPane.ERROR_MESSAGE);
            }
            else
            {
                File[] files = chooser.getSelectedFile().listFiles();
                for (int i=0; i<files.length; i++) {
                    if(files[i].isFile()){
                        if(files[i].toString().equals(chooser.getSelectedFile().toString()+"\\build.xml")){
                            isValid = true;
                            break;
                        }
                    }
                }
                if(isValid){
                    currDirFile = chooser.getSelectedFile();
                    txt_diractual.setText(currDirFile.toString());
                    btn_ant.setEnabled(true);
                    btn_antdeploy.setEnabled(true);
                    btn_antupdate.setEnabled(true);
                    btn_antgeneratewp.setEnabled(true);
                    btn_dependencies_flex.setEnabled(true);
                    btn_dependencies_java.setEnabled(true);
                    btn_dependencies_web.setEnabled(true);
                    btn_generate_tar.setEnabled(true);
                    btn_custom_comm.setEnabled(true);
                }
                else{
                    JOptionPane.showMessageDialog(null, "No es una carpeta válida","ERROR", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    }//GEN-LAST:event_btn_selproyActionPerformed

    private void btn_antActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_antActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
            btn_antdeploy.setEnabled(true);
            } catch (IOException ex) {
                Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
            }
    }//GEN-LAST:event_btn_antActionPerformed

    private void btn_antdeployActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_antdeployActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant deploy_web");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_antdeployActionPerformed

    private void btn_antupdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_antupdateActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant update_web");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_antupdateActionPerformed

    private void btn_antgeneratewpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_antgeneratewpActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant generate_workspace");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_antgeneratewpActionPerformed

    private void btn_generate_tarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_generate_tarActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant generate_tar");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_generate_tarActionPerformed

    private void btn_dependencies_javaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_dependencies_javaActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant dependencies_java");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_dependencies_javaActionPerformed

    private void btn_dependencies_flexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_dependencies_flexActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant dependencies_flex");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_dependencies_flexActionPerformed

    private void btn_dependencies_webActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_dependencies_webActionPerformed
        try {
            areaCon.setText("");
            ProcessBuilder process = new ProcessBuilder("cmd","/C","ant dependencies_web");
            process.directory(currDirFile);
            Process javap = process.start();
            StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
            outputGobbler.start();
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_dependencies_webActionPerformed

    private void btn_clearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_clearActionPerformed
        areaCon.setText("");
    }//GEN-LAST:event_btn_clearActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        Runtime r = Runtime.getRuntime();
        try {
            generalProper = InitProperties.getEclipsePath();
            if(generalProper.getProperty(PathContainer.ECLIPSEPATH) != null){
                Process p = r.exec(generalProper.getProperty(PathContainer.ECLIPSEPATH));
            }
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Error de E/S","ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            if(!txt_diractual.getText().equals("")){
                ProcessBuilder process = new ProcessBuilder("C:\\Windows\\Explorer.exe", txt_diractual.getText());
                Process wexplorer = process.start();
            }
            else{
                ProcessBuilder process = new ProcessBuilder("C:\\Windows\\Explorer.exe", generalProper.getProperty("defaultDir"));
                Process wexplorer = process.start();
            }
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        Runtime r = Runtime.getRuntime();
        try {
            generalProper = InitProperties.getPuttyPath();
            if(generalProper.getProperty(PathContainer.PUTTYPATH) != null){
                Process p = r.exec(generalProper.getProperty(PathContainer.PUTTYPATH));
            }
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Error de E/S","ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        Runtime r = Runtime.getRuntime();
        try {
            generalProper = InitProperties.getSqldevPath();
            if(generalProper.getProperty(PathContainer.SQLDEVPATH) != null){
                Process p = r.exec(generalProper.getProperty(PathContainer.SQLDEVPATH));
            }
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Error de E/S","ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        Runtime r = Runtime.getRuntime();
        try {
            generalProper = InitProperties.getWinscpPath();
            if(generalProper.getProperty(PathContainer.WINSCPPATH) != null){
                Process p = r.exec(generalProper.getProperty(PathContainer.WINSCPPATH));
            }
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Error de E/S","ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void btn_custom_commActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_custom_commActionPerformed
        txt_custom_command.setEnabled(true);
    }//GEN-LAST:event_btn_custom_commActionPerformed

    private void btn_executeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_executeActionPerformed
        if(!txt_custom_command.getText().startsWith("ant")){
            JOptionPane.showMessageDialog(null, "Verifique el comando","ERROR", JOptionPane.ERROR_MESSAGE);
        }
        else{
            Runtime r = Runtime.getRuntime();
            try{
                areaCon.setText("");
                ProcessBuilder process = new ProcessBuilder("cmd","/C", txt_custom_command.getText());
                process.directory(currDirFile);
                Process javap = process.start();
                StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
                outputGobbler.start();
                btn_execute.setEnabled(false);
                txt_custom_command.setEnabled(false);
                flagKeyPress = false;
            }
            catch (IOException ex) {
                Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_btn_executeActionPerformed

    private void txt_custom_commandKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_custom_commandKeyTyped
        if(!flagKeyPress){
            btn_execute.setEnabled(true);
            flagKeyPress = true;
        }
    }//GEN-LAST:event_txt_custom_commandKeyTyped

    private void txt_custom_commandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_custom_commandActionPerformed
        if(!txt_custom_command.getText().startsWith("ant")){
            JOptionPane.showMessageDialog(null, "Verifique el comando","ERROR", JOptionPane.ERROR_MESSAGE);
        }
        else{
            Runtime r = Runtime.getRuntime();
            try{
                areaCon.setText("");
                ProcessBuilder process = new ProcessBuilder("cmd","/C", txt_custom_command.getText());
                process.directory(currDirFile);
                Process javap = process.start();
                StreamGobbler outputGobbler = new StreamGobbler(javap.getInputStream(), areaCon, scrollCon);
                outputGobbler.start();
                btn_execute.setEnabled(false);
                txt_custom_command.setEnabled(false);
                flagKeyPress = false;
            }
            catch (IOException ex) {
                Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_txt_custom_commandActionPerformed

    private void btn_wikiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_wikiActionPerformed
        String target = "http://bahq55:8090/wiki/jsp/Wiki?AtuinFramework";
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " +target);
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_wikiActionPerformed

    private void btn_ambientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ambientesActionPerformed
        String target = "http://bahq55:8100/com/wiki/Ambientes";
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " +target);
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_ambientesActionPerformed

    private void btn_artifactoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_artifactoryActionPerformed
        String target = "http://bahq55:40000/artifactory/";
        try {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " +target);
        } catch (IOException ex) {
            Logger.getLogger(AntGeneratorGUIView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_artifactoryActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JTextArea areaCon;
    private javax.swing.JButton btn_ambientes;
    private javax.swing.JButton btn_ant;
    private javax.swing.JButton btn_antdeploy;
    private javax.swing.JButton btn_antgeneratewp;
    private javax.swing.JButton btn_antupdate;
    private javax.swing.JButton btn_artifactory;
    private javax.swing.JButton btn_clear;
    private javax.swing.JButton btn_custom_comm;
    private javax.swing.JButton btn_dependencies_flex;
    private javax.swing.JButton btn_dependencies_java;
    private javax.swing.JButton btn_dependencies_web;
    private javax.swing.JButton btn_execute;
    private javax.swing.JButton btn_generate_tar;
    private javax.swing.JButton btn_selproy;
    private javax.swing.JButton btn_wiki;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPanel panel_apps;
    private javax.swing.JScrollPane scrollCon;
    private javax.swing.JTextField txt_custom_command;
    private javax.swing.JTextField txt_diractual;
    // End of variables declaration//GEN-END:variables

    private JDialog aboutBox;
    private JDialog dialogOpciones;
}